<html>
<head>
<title>k3.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #cc7832;}
.s1 { color: #a9b7c6;}
.s2 { color: #6a8759;}
.s3 { color: #808080;}
.s4 { color: #6897bb;}
</style>
</head>
<body bgcolor="#2b2b2b">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
k3.java</font>
</center></td></tr></table>
<pre><span class="s0">import </span><span class="s1">java.util.Scanner</span><span class="s0">;</span>

<span class="s0">public class </span><span class="s1">k3{</span>
    <span class="s0">public static void </span><span class="s1">main(String[] args) {</span>
        <span class="s1">Scanner scanner = </span><span class="s0">new </span><span class="s1">Scanner(System.in)</span><span class="s0">;</span>
        <span class="s1">System.out.print(</span><span class="s2">&quot;请输入年终奖金额（元）：&quot;</span><span class="s1">)</span><span class="s0">;</span>
        <span class="s0">double </span><span class="s1">bonus = scanner.nextDouble()</span><span class="s0">;</span>

        <span class="s3">// 定义税率表（上限，税率%，速算扣除数）</span>
        <span class="s0">int</span><span class="s1">[][] taxTable = {</span>
                <span class="s1">{</span><span class="s4">3000</span><span class="s0">, </span><span class="s4">3</span><span class="s0">, </span><span class="s4">0</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{</span><span class="s4">12000</span><span class="s0">, </span><span class="s4">10</span><span class="s0">, </span><span class="s4">210</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{</span><span class="s4">25000</span><span class="s0">, </span><span class="s4">20</span><span class="s0">, </span><span class="s4">1410</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{</span><span class="s4">35000</span><span class="s0">, </span><span class="s4">25</span><span class="s0">, </span><span class="s4">2660</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{</span><span class="s4">55000</span><span class="s0">, </span><span class="s4">30</span><span class="s0">, </span><span class="s4">4410</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{</span><span class="s4">80000</span><span class="s0">, </span><span class="s4">35</span><span class="s0">, </span><span class="s4">7160</span><span class="s1">}</span><span class="s0">,</span>
                <span class="s1">{Integer.MAX_VALUE</span><span class="s0">, </span><span class="s4">45</span><span class="s0">, </span><span class="s4">15160</span><span class="s1">}</span>
        <span class="s1">}</span><span class="s0">;</span>

        <span class="s0">double </span><span class="s1">monthlyTaxable = bonus / </span><span class="s4">12.0</span><span class="s0">;</span>
        <span class="s0">int </span><span class="s1">rate = </span><span class="s4">3</span><span class="s0">;</span>
        <span class="s0">int </span><span class="s1">deduction = </span><span class="s4">0</span><span class="s0">;</span>

        <span class="s0">for </span><span class="s1">(</span><span class="s0">int</span><span class="s1">[] bracket : taxTable) {</span>
            <span class="s0">if </span><span class="s1">(monthlyTaxable &lt;= bracket[</span><span class="s4">0</span><span class="s1">]) {</span>
                <span class="s1">rate = bracket[</span><span class="s4">1</span><span class="s1">]</span><span class="s0">;</span>
                <span class="s1">deduction = bracket[</span><span class="s4">2</span><span class="s1">]</span><span class="s0">;</span>
                <span class="s0">break;</span>
            <span class="s1">}</span>
        <span class="s1">}</span>

        <span class="s0">double </span><span class="s1">tax = bonus * rate / </span><span class="s4">100.0 </span><span class="s1">- deduction</span><span class="s0">;</span>
        <span class="s0">double </span><span class="s1">netAmount = bonus - tax</span><span class="s0">;</span>

        <span class="s1">System.out.printf(</span><span class="s2">&quot;纳税金额：%.2f 元，实发金额：%.2f 元%n&quot;</span><span class="s0">, </span><span class="s1">tax</span><span class="s0">, </span><span class="s1">netAmount)</span><span class="s0">;</span>
    <span class="s1">}</span>
<span class="s1">}</span>

<span class="s3">// 测试案例：</span>
<span class="s3">// 输入36000元：纳税金额1080.00元，实发34920.00元</span>
<span class="s3">// 输入36001元：纳税金额3390.10元，实发32610.90元</span></pre>
</body>
</html>